home *** CD-ROM | disk | FTP | other *** search
- program CliePull;
- {$APPTYPE CONSOLE}
- uses
- SysUtils, Windows, Classes, Graphics, JPEG;
-
- const
- Head: array[0..26] of char = 'content-type: image/jpg'#13#10#13#10;
- var
- hForeignWin: THandle;
- wDC: HDC;
- SrcRect: TRect;
- Bitmap: TBitmap;
- AStream: TMemoryStream;
- Buffer: array[0..8191] of Byte;
- BytesToSend: Integer;
- begin
- Rewrite(Output);
- FileWrite(TTextRec(Output).Handle, Head, SizeOf(Head));
-
- Bitmap := TBitmap.Create;
- with Bitmap do
- try
- hForeignWin := FindWindow('System Monitor', 'System Monitor');
- try
- SetForegroundWindow(hForeignWin);
- RedrawWindow(hForeignWin, nil, 0, RDW_INVALIDATE+RDW_UPDATENOW);
- GetWindowRect(hForeignWin, SrcRect);
- Width := SrcRect.Right-SrcRect.Left;
- Height := SrcRect.Bottom-SrcRect.Top;
- wDC := GetWindowDC(hForeignWin);
- BitBlt(Canvas.Handle, 0, 0, Width, Height, wDC, 0, 0, SRCCOPY);
- with TJPEGImage.Create do
- try
- Assign(Bitmap);
- AStream := TMemoryStream.Create;
- try
- SaveToStream(AStream);
- AStream.Seek(soFromBeginning, 0);
- while AStream.Position < AStream.Size do
- begin
- BytesToSend := AStream.Read(Buffer, SizeOf(Buffer));
- FileWrite(TTextRec(Output).Handle, Buffer, BytesToSend);
- end;
- finally
- AStream.Free;
- end;
- finally
- Free;
- end;
- finally
- ReleaseDC(hForeignWin, wDC);
- end;
- finally
- Bitmap.Free;
- end;
- end.
-